{# src/Site/GeneralBundle/Resources/views/Default/index.twig.html #}
{# Autheur : Brett Choquet , Barthélémy Antonin #}

{% extends "::layout.html.twig" %}

{% block title %}
Gestion - Facebook - {{ parent() }}
{% endblock %}

{% block body %}
<div class="jumbotron">
  <h1>Gestion module Facebook</h1>
  <p class="lead">
    Ce module permet d'avoir un contrôle administrateur sur les groupes Facebook des projets. Il est possible de les consulter, d'envoyer un message à un groupe spécifique ou à tous et de les détruire/ouvrir. </p>
</div>

<div class="well">
  <ul class="nav nav-tabs">
    <li class="active"><a href="#listeGroupes" data-toggle="tab">Liste groupes</a></li>
    <li><a href="#envoyerMessage" data-toggle="tab">Envoyer message</a></li>
    <li><a href="#gestionGroupes" data-toggle="tab">Gérer groupes</a></li>
  </ul>
  
  <div class="tab-content">
    <div class="tab-pane active" id="listeGroupes">
      {% for group in groups.data %}
      {% if loop.index0 is divisibleby(6) %}
      <div class="row" style="margin-top:20px">
	{% endif %}
	<div class="col-xs-3 col-md-2">
	   <a href="{{ path('site_facebook_display_homepage',{ 'groupId': group['id'] } ) }}"> <button type="button" class="btn btn-primary btn-lg" style="width:100%">
	      <span class="glyphicon glyphicon-comment"></span>  {{ group['name'] }}
	    </button></a>
	</div>
	{% if loop.index is divisibleby(6) or loop.last %}
      </div>
      {% endif %}
      {% endfor %}
    
    </div>



    
    <div class="tab-pane" id="envoyerMessage">
      <div class="well well">
	<form role="form" action="{{ path('site_facebook_display_message') }}">
	  <div class="radio">
	    <label> 
	      <input type="radio" name="teakts" value="MessageGroupe" id="MessageGroupe" onClick="cacher();" checked/>
	      Message en HotLine
	    </label>
	  </div>
	  <div class="radio">
	    <label> 
	      <input type="radio" name="teakts" value="messageCible" id="MessageCible" onClick="afficher();"/>
	      Message ciblé
	    </label>
	  </div>
	  <select class="form-control" id="champ_cache" name="cible">
	    {% for group in groups.data %}
	    <option value="{{ group.id }}">{{ group.name }}</option>
	    {% endfor %}
	  </select>
	  <div class="form-group">
	    <label>Message</label>
	    <textarea name="message" class="form-control" rows="10" style="resize:vertical;" placeholder="Ecrivez ici !"></textarea>
	    </br>
	  </div>
	  <button type="submit" class="btn btn-success">Envoyer</button>
	  <button type="reset" class="btn btn-danger" onClick="cacher();">Effacer</button>
	</form>
      </div>
    </div>
  
      
      <script type="text/javascript">
	document.getElementById("champ_cache").style.display = "none";
	
	function afficher()
	{
	document.getElementById("champ_cache").style.display = "block";
	}
	
	function cacher()
	{
	document.getElementById("champ_cache").style.display = "none";
	}
      </script>
      
      <div class="tab-pane" id="gestionGroupes">
	<br />
	<form action="{{ path('site_facebook_display_creerGroup') }}">
	  <div class="input-group input-group-lg">
	    <span class="input-group-addon">
	    <button type="submit" class="btn btn-info btn-xs"> 
	      <span class="glyphicon glyphicon-plus"></span>
	    </button>
	  </span>
	  <input type="text" name="idgroup" class="form-control" placeholder="Creer un groupe Facebook">
	</form>
	</div>

	<div>
	 
	  <div class="tab-pane active" id="listeGroupes">
	    {% for group in groups.data %}
	    {% if loop.index0 is divisibleby(3) %}
	    <div class="row" style="margin-top:20px">
	      {% endif %}
	      <div class="col-xs-4 col-md-4">
		<div class="panel panel-primary">
		  <div class="panel-heading">
		    {{ group.name }}
		    <a href="{{ path('site_facebook_display_suprimerGroup',{ 'groupId': group['id'] } ) }}"><button class="btn btn-danger btn-xs pull-right" ><span class="glyphicon glyphicon-remove"></span></button></a>
		  </div>
		  <div class="panel-body">
		    <!-- Appelle le controleur pour supprimer un membre. Nom du groupe en parametre -->
		    <form action="">
		      <select name="member" class="btn btn-info">
			{% if group.members.data is defined %}
			{% for member in group.members.data %}
			<option value="{{ member.id }}">{{ member.name }}</option>
			{% endfor %}
		      </select>
		      {% else %}
		      <option> Personne ici ... <option>
			</select>
                       {% endif %}

                     </form>

		  </div>
		</div>
	      </div>
	      {% if loop.index is divisibleby(3) or loop.last %}
	    </div>
	    {% endif %}
	    {% endfor %}
	    
	  </div>
	  
	</div>

      </div>
      
  </div>
</div>
  {% endblock %}


